<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <title>主页</title>
</head>
<body>
<form id="formDataForm">
    <p>收件人：<input type="text" name="username"/></p>
    <p>主题：<input type="text" name="topic"/></p>
    <p>内容：<input type="text" name="content"/></p>
    <input type="button" id="testBtn" value="发送邮件"/>
</form>
<script type="text/javascript" src="/js/jquery-1.11.1.min.js"></script>

<script type="text/javascript">
    $(function () {
        $('#testBtn').click(function () {
            $.ajax({
                type: 'POST',
                url: 'mail/send',
                data: $('#formDataForm').serialize(),
                dataType: 'json',
                success: function (data) {
                    console.log(data)
                },
                error: function (xhr, type) {
                    alert('Ajax error!')
                }
            });
        });
    });
</script>
</body>
</html>